var dm2d = new ht.DataModel();
var dm3d = new ht.DataModel();
var g2d = new ht.graph.GraphView();
var g3d = new ht.graph3d.Graph3dView(dm3d);

window.addEventListener('load', function() {
	
	dragFunc("idOuterDiv");
	var htDom = document.getElementById("ht");
	
    g3d.addToDOM(htDom);
	
	g3d.deserialize('scenes/bigScreen3ds.json', function(json, dm, g3d, datas){
      g3d.setEye([2542,834,22]);
      g3d.setCenter([0,600,0]);
    });
	
    g3d.handleScroll = function(){};    // 关闭拓扑的滚轮缩放
    g3d.handlePinch = function(){};    // 禁用touch上双指操作缩放
    g3d.setRotatable(false);
    g3d.setPannable(false);
	
    g2d.addToDOM(htDom);
    g2d.addToDOM(g3d.getView());
    g2d.deserialize('displays/bigScreen0110.json');
    g2d.handleScroll = function(){};    // 关闭拓扑的滚轮缩放
    g2d.handlePinch = function(){};    // 禁用touch上双指操作缩放
    setInterval("getArround()",50);
    
    setInterval("news()",75);
    
    setInterval(function(){
    	         var time=new Date();
    	         var year=time.getFullYear(); //获取年份
    	         var month=time.getMonth()+1; //获取月份
    	         var day=time.getDate();  //获取日期
    	         var hour=checkTime(time.getHours());  //获取时
    	         var minite=checkTime(time.getMinutes()); //获取分
    	         var second=checkTime(time.getSeconds()); //获取秒
    	         /****当时、分、秒、小于10时，则添加0****/
    	         function checkTime(i){
    	             if(i<10) return "0"+i;
    	             return i;
    	         }
//    	         var box=document.getElementById("time");
//    	         box.innerHTML=year+"年"+month+"月"+day+"日 "+hour+":"+minite+":"+second;       
//    			console.log(year+"-"+month+"-"+day+" "+hour+":"+minite+":"+second);
    			var timeNode = g2d.dm().getDataByTag("timeTag");
    			timeNode.s({"text": year+"-"+month+"-"+day+" "+hour+":"+minite+":"+second});
    			
	        },1000);
    
    $("#idOuterDiv").bind('dblclick',function(){
    	$("#idOuterDiv").css("display","none");
    	$("#subSys").css("display","none");
    	$("#ht").css("display","");
    	$("#subsysFrame").attr('src',"");
    });
    
    setTimeout("loadDiseaseCondition()",2000);
});

function getArround(){
	var node = g3d.dm().getDataByTag("circle");
	var r = node.r3();
	node.r3([r[0],r[1]+0.02,r[2]]);
	
	var earthNode = g3d.dm().getDataByTag("earth");
	var earthRotation = node.r3();
	earthNode.r3([earthRotation[0],earthRotation[1]+0.02,earthRotation[2]]);
}

var count = 0;
function news(){
	let node = g3d.dm().getDataByTag("news");
	if(count < 120){
		count ++;
	}else{
		count = 0
	}
	node.setRotationZ(Math.PI/60*count);
}

function turnArround(){
	var arroundModuleNode = dataModel.getDataByTag("arroundModule");
	var rotation = arroundModuleNode.getRotation();
	arroundModuleNode.setRotation(rotation+0.05);
	setTimeout("turnArround()", 50);
}


function turnPage(page){
	$("#subSys").css("display","inline-block");
	$("#idOuterDiv").css("display","inline-block");
	
	if(page=='1'){
		window.location.href='http://10.1.49.48:8080/TYMH/tymh/fullPage/getFullPageUrl?id=991c988f3cb34177a4620b5f5799cd63';
	}
	if(page=='2'){
		window.location.href='http://10.1.49.48:8080/TYMH/tymh/fullPage/getFullPageUrl?id=81caf4ee57074fca9aa5c7ce31b9b486';
	}
	if(page=='3'){
		window.location.href='http://10.1.38.140:8001/DataCenter.aspx';
	}
	if(page=='4'){
		window.location.href='http://10.1.49.48:8080/TYMH/static/indexShow/index.html';
	}
	if(page=='5'){
		//location.href='/bigScreen/ali';
	}
	if(page=='6'){
		location.href='http://172.20.22.4';
	}
	if(page=='7'){
	}
	if(page=='8'){
		window.location.href='http://172.20.46.4:8171/';
	}
	if(page=='9'){
		window.location.href='http://172.20.22.4/#/dashboard/network';
	}
	if(page=='11'){
		window.location.href='/bigScreen/resource';
//		window.location.href='http://10.2.129.68:8080/res/base/login.do';
	}
	if(page=='12'){
		location.href='/bigScreen/company';
	}
	if(page=='13'){
		location.href='/bigScreen/maintain';
	}
	if(page=='14'){
		location.href='/bigScreen/operation';
	}
	if(page=='15'){
		location.href='/bigScreen/construction';
	}
	if(page=='16'){
		location.href='http://172.20.41.38:8076/ncp/pages/equip/temperaturen.jsp';
	}
	if(page=='operationSecondLevel'){
		location.href='/bigScreen/operation/operationSecondLevel';
	}
	if(page=='sssbzbkj'){
		location.href='/bigScreen/maintain/sssbzbkj';
	}
	if(page=='jsglzbkj'){
		location.href='/bigScreen/construction/jsglzbkj';
	}
	if(page=='qyglzbkj'){
		location.href='/bigScreen/company/qyglzbkj';
	}
}



var arr = [];

function gotoSubsys(sysid){
	$("#subSys").css("display","inline-block");
	$("#idOuterDiv").css("display","inline-block");
	$("#ht").css("display","none");
	
	if(sysid=='1'){
		window.location.href='https://datav.aliyun.com/share/97b946c5235fe537d260bd3bca9a0f22';
	}
	if(sysid=='2'){
		window.location.href='http://datav.aliyun.com/share/ef2815bdd8783f821a7a24109725b3f0';
	}
	if(sysid=='3'){
		window.location.href='http://datav.aliyun.com/share/e980c32a344162ed1e88ff0f0f00da86';
	}
	if(sysid=='4'){
		window.location.href='http://10.1.49.48:8080/TYMH/static/indexShow/index4wb.html';
	}
//	if(sysid=='5'){
//		window.location.href='http://10.2.140.131:8087/shior/templates/show.html';
//	}改到function gotoSubsysCar(car)
	if(sysid=='6'){
		window.location.href='http://10.1.49.48:8080/TYMH/static/indexShow/index.html';
	}
	if(sysid=='7'){
		window.location.href='http://10.1.38.140:8001/DataCenter.aspx';
	}
	if(sysid=='8'){
		window.location.href='http://datav.aliyuncs.com/share/2ea612f80b66ddd4e2661609ce79202b';
	}
	if(sysid=='9'){
		window.location.href='http://datav.aliyuncs.com/share/c40e89a8ccf5c7a5d9d52d6eb98fa063';
	}
	if(sysid=='10'){
		window.location.href='http://fkyq.shmetro.com:8088/fg/fullloadPC';
	}
	
	for(var h=0;h<arr.length;h++){
	    let node = g2d.dm().getDataByTag(arr[h]);
	    node.s("2d.visible",false);
	}
}


function gotoSubsysCar(car){
	if(car == '1701'){
		window.location.href='http://10.2.140.131:8087/shior/templates/show.html?page=train&line=17&train=1701&type=17A01';
	}
	if(car == '1703'){
		window.location.href='http://10.2.140.131:8087/shior/templates/show.html?page=train&line=17&train=1703&type=17A01';
	}
	if(car == '0402'){
		window.location.href='http://10.2.140.131:8087/shior/templates/show.html?page=train&line=4&train=0402&type=04A01';
	}
	if(car == '0403'){
		window.location.href='http://10.2.140.131:8087/shior/templates/show.html?page=train&line=4&train=0403&type=04A01';
	}
}

//加载疫情数据
function loadDiseaseCondition(){
	$.ajax({
		url:baseUrl+"oper/queryYQ",
		type:'post',
		success:function(data){
			let node = g2d.dm().getDataByTag("ksgrs");
			node.s('text',data.kfgrs);
			let node1 = g2d.dm().getDataByTag("zwdrs");
			node1.s('text',data.qwdzrs);
			let node2 = g2d.dm().getDataByTag("ysrs");
			node2.s('text',data.ys);
			let node3 = g2d.dm().getDataByTag("qzrs");
			node3.s('text',data.qz);
		}
	});
}



